﻿using Api.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace Api.Web
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            //using (var db = Db.Current)
            //{
            //    var objectContext = ((IObjectContextAdapter)db).ObjectContext;
            //    var mappingCollection = (System.Data.Entity.Core.Mapping.StorageMappingItemCollection)objectContext.MetadataWorkspace.GetItemCollection(System.Data.Entity.Core.Metadata.Edm.DataSpace.CSSpace);
            //    mappingCollection.GenerateViews(new System.Collections.Generic.List<System.Data.Entity.Core.Metadata.Edm.EdmSchemaError>());
            //}

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            //MiniProfilerEF6.Initialize();
        }
        protected void Application_BeginRequest()
        {
            //if (Request.Url.Authority.StartsWith("local"))
            //{
                
            //    MiniProfiler.Start();
            //}
        }

        protected void Application_EndRequest()
        {
            //MiniProfiler.Stop();
        }
    }
}
